home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / bp7bugs1.zip / TRASHSRC.ZIP / TRASH.DOC < prev    next >
Text File  |  1993-01-03  |  4KB  |  93 lines

  1. TrashDet, TrashRep, TrashFix and Prot386 - Trash detection and repair
  2.    by D.J. Murdoch
  3.  
  4. SYNTAX:
  5.  
  6.   TRASHDET
  7.     installs TSR detector
  8.   TRASHREP
  9.     gives report of which registers have been trashed, if any
  10.   TRASHFIX
  11.     fixes trashing of EAX, EBX, ECX, EDX, ESI, EDI, EBP, FS and GS by
  12.     any of the 16 standard hardware interrupts
  13.  
  14. DESCRIPTION:
  15.  
  16. Borland Pascal 7 introduced 32 bit arithmetic for longints, which gives
  17. a performance boost over 16 bit arithmetic.  Unfortunately, it's not
  18. safe on some PCs: those running software that trashes the extended
  19. registers.
  20.  
  21. The best fix for this would be to replace that buggy software, but
  22. that's not an option in most cases.  An alternative would be to install
  23. a TSR that saved and restored the trashed registers, but to do that, you
  24. really need to the details of which registers get trashed and by what.
  25.  
  26. Figuring that out is the purpose of TrashDet.  It installs interrupt
  27. handlers on all 16 hardware interrupts (08 thru 0F, and 70 thru 77).  It
  28. counts how often the high word of registers EAX, EBX, ECX, EDX, ESI,
  29. EDI, or EBP, or the segment registers FS or GS get  modified by the
  30. interrupt handler.  These registers should *never* be modified, so any
  31. report signals a bug in the interrupt service routine that was in place
  32. before TrashDet.  (All of this in 608 bytes of memory when resident -
  33. not bad for a TSR written in TP, is it? :-)
  34.  
  35. TrashRep is a simple report program to look in the TrashDet tables, and
  36. report if any errors have been detected.  It reports the error counts.
  37. Note that since single bytes are used for the counting, the counts roll
  38. over at 256.
  39.  
  40. As a side benefit, TrashDet restores the trashed registers, so it could
  41. be used as a stopgap repair - but a much smaller and faster TSR could be
  42. written to handle only the cases reported by TrashRep.
  43.  
  44. TrashFix is a somewhat smaller and faster general fixup TSR.  It's
  45. almost the same as TrashDet, but doesn't do any counting of cases where
  46. the fixup was necessary.  (In fact, the two programs share the same
  47. source code, with only a compiler conditional define to separate them.)
  48. It hooks interrupts 08 thru 0F and 70 thru 77, and saves and restores
  49. the top word of the registers EAX, EBX, ECX, EDX, ESI, EDI and EBP, and
  50. segment registers FS and GS. (TrashFix takes only 480 bytes of memory
  51. when resident. :-)
  52.  
  53. I've also included a BP 7 unit (PROT386.PAS) that installs a streamlined
  54. version of TRASHFIX just for the duration of a TP program.  This version
  55. only saves the high words of EAX thru EDX; those are the only extended
  56. registers used by TP programs.
  57.  
  58. SOURCE CODE
  59.  
  60. Full source code for TrashDet and TrashFix is supplied in Trashdet.pas,
  61. and for TrashRep in Trashrep.pas.  Feel free to modify these to suit
  62. your own requirements.  Please let me know (see below for how) if you
  63. notice any bugs.
  64.  
  65. OTHER PROGRAMS
  66.  
  67. Just for fun, I've included a program (MESS386) that messes up the extended
  68. registers, and another (TEST) that shows this does to longint calculations.
  69. On my 486-33, it prints errors about 2 or 3 times a minute.  Uncomment the
  70. "uses prot386" line in TEST.PAS and recompile, and you shouldn't see any
  71. errors at all.
  72.  
  73.  
  74. LICENSE
  75.  
  76. I've donated these programs to the public domain, so there's no legal
  77. license needed at all.  However, I place the following moral requirement
  78. on any user:  if TrashDet ever helps you to detect that an ISR is
  79. trashing the extended registers, you must make an effort to determine
  80. which program has the bug, and inform the author of the program and any
  81. other users you can contact.  If it's a widely distributed commercial
  82. program, I'd also appreciate hearing about it.
  83.  
  84. I can be contacted at the following addresses:
  85.  
  86.    Internet:    dmurdoch@mast.queensu.ca
  87.    Compuserve:  71631,122
  88.    Fidonet:     DJ Murdoch at 1:249/99.5
  89.    Postal:      D. J. Murdoch
  90.                 337 Willingdon Ave.
  91.                 Kingston, Ontario, Canada
  92.                 K7L 4J3
  93.